<!--
 * @Author: C.
 * @Date: 2021-06-10 17:03:24
 * @LastEditTime: 2021-06-10 19:34:45
 * @Description: file content
-->
<template>
  <el-button size="mini"
             :type="btnType[type].type"
             :title="btnType[type].title"
             @click="btnClick"
             circle
             :disabled="disabled">
    <!-- 图标 -->
    <i slot="default"
       :class="btnType[type].icon"></i>
  </el-button>
</template>

<script>
import { btnType } from "./btnType";
export default {

  data () {
    return {
      // 按钮枚举
      btnType: btnType,
    }
  },
  methods: {
    // 抛出点击事件
    btnClick () {
      if (this.btnType[this.type].confirm) {
        this.$confirm(this.btnType[this.type].confirm, '确认信息', {
          distinguishCancelAndClose: true,
          confirmButtonText: '确认',
          cancelButtonText: '取消'
        }).then(() => {
          this.$emit('click')
        })
      } else {
        this.$emit('click')
      }
    }
  },
  props: {
    //  自定义类型
    type: {
      type: String,
      default: 'edit'
    },
    // 是否禁用
    disabled: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style>
</style>
